using UnityEngine;

public class CatmullRomSplineBallFlight : BallFlight
{
	protected SplineVector3 positionSpline = new SplineVector3();

	protected SplineVector3 velocitySpline = new SplineVector3();

	protected SplineVector3 angularVelocitySpline = new SplineVector3();

	public void SetIsDeltaTimeBetweenControllPointsConstant(bool isConstant)
	{
		positionSpline.isDeltaTimeBetweenAllSplinePointsConstant = isConstant;
		velocitySpline.isDeltaTimeBetweenAllSplinePointsConstant = isConstant;
		angularVelocitySpline.isDeltaTimeBetweenAllSplinePointsConstant = isConstant;
	}

	public void AddControlPoint(FlightParams newPoint, float time)
	{
		positionSpline.Add(newPoint.position, time);
		velocitySpline.Add(newPoint.velocity, time);
		angularVelocitySpline.Add(newPoint.angularVelocity, time);
	}

	public void Clear()
	{
		positionSpline.Clear();
		velocitySpline.Clear();
		angularVelocitySpline.Clear();
	}

	public override void ReturnToPool()
	{
		base.ReturnToPool();
		Clear();
	}

	public override void SetInitialConditions(FlightParams initialConditions, PhysicsBall ball)
	{
	}

	public override void Reset()
	{
		base.flightTime = 0f;
	}

	public override void Update(float deltaTime)
	{
		base.flightTime += deltaTime;
	}

	public override Vector3 Position()
	{
		return PositionAt(base.flightTime);
	}

	public override Vector3 Velocity()
	{
		return VelocityAt(base.flightTime);
	}

	public override Vector3 AngularVelocity()
	{
		return AngularVelocityAt(base.flightTime);
	}

	public override Vector3 PositionAt(float time)
	{
		return positionSpline.ValueAtTime(time);
	}

	public override Vector3 VelocityAt(float time)
	{
		return velocitySpline.ValueAtTime(time);
	}

	public override Vector3 AngularVelocityAt(float time)
	{
		return angularVelocitySpline.ValueAtTime(time);
	}
}
